package com.test.Servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.test.daoImp.UpdateDaoImp;
import com.test.database.DBUtil;
import com.test.entity.WriteEntity;

@WebServlet("/com/test/servlet/updateTestcase")
public class updateTestcase extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		System.out.println("获取前端更新数据");
		
		int id = Integer.parseInt(request.getParameter("count"));
		String utitle = request.getParameter("updatetitle");
		String uname = request.getParameter("updatename");
		String utype = request.getParameter("updatetype");
		String utext = request.getParameter("updateText");
		String ueResults = request.getParameter("ueResults");
		String uaResults = request.getParameter("uaResults");
		
		
		System.out.println("将数据保存在实体类中  text"+id+utitle);
		
		//将数据装入数据实体
		WriteEntity data = new WriteEntity();
		
		data.setId(id);
		data.setTitle(utitle);
		data.setType(utype);
		data.setName(uname);
		data.setText(utext);
		data.setExpectResults(ueResults);
		data.setActualResults(uaResults);
		
		UpdateDaoImp ui = new UpdateDaoImp();
		boolean flag = ui.update_tb_article_info(data);
		
		// 调用数据访问层  写入数据库
		if(flag) {
					
			// 发表成功
			response.sendRedirect("/Test_Project/findServlet.do");
			System.out.println("更新用例成功");
		}else {
			response.sendRedirect("/Test_Project/updateTestcase.jsp");
			System.out.println("更新用例失败....");
		}
	}



}


